<?php
class TermsRelationships extends CActiveRecord {
	public static function model($className = __CLASS__) {
		return parent::model($className);
	}

	public function tableName() {
		return strtolower('TermsRelationships');
	}

	public function rules() {
		return array(
//			array('objectId, subjectId', 'unique')
		);
	}
	
	public function relations() {
		return array(
			'topics' => array(self::BELONGS_TO, 'TermsTaxonomy', 'subjectId',
				'on' => 'termTaxonomyId = subjectId',
//				'together' => true,
				'joinType' => 'INNER JOIN',
				'condition' => 'taxonomy = "'.TermsTaxonomy::TAXONOMY_TOPIC.'"'
			),
			'categories' => array(self::BELONGS_TO, 'TermsTaxonomy', 'subjectId',
				'on' => 'termTaxonomyId = subjectId',
//				'together' => true,
				'joinType' => 'INNER JOIN',
				'condition' => 'taxonomy = "'.TermsTaxonomy::TAXONOMY_CATEGORY.'"'
			)
		);
	}
}
